<html>
    <head>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
        <title><?=$layout[MY_Controller::META_TITLE]?></title>
        <meta name="keywords" content="<?=$layout[MY_Controller::META_DESCRIPTION]?>">
        <meta name="description" content="<?=implode(", ",$layout[MY_Controller::META_KEYWORDS])?>">
        
        <!-- Css common files -->
        <?php
        if(!empty($layout[MY_Controller::CSS_FILES]))
        {
            foreach ($layout[MY_Controller::CSS_FILES] as &$css_file)
            {
                echo "<link href='".site_url()."css/{$css_file}.css?r={$version}' rel='stylesheet' type='text/css' media='screen' />\n";    
            }
        }
        ?>

        <!-- Javascript global var -->
        <script>
        <? 
        if(!empty($layout[MY_Controller::JS_VARS]))
        {
            foreach($layout[MY_Controller::JS_VARS] as $var_name => &$var_value)
            {
                if(is_string($var_value))       echo "var {$var_name} = '{$var_value}' ;\n";
                elseif(is_integer($var_value))  echo "var {$var_name} = {$var_value} ;\n";
                elseif(is_bool($var_value))     echo "var {$var_name} = ".($var_value? 'true' : 'false')." ;\n";
                elseif(is_array($var_value) || is_object($var_value))     echo "var {$var_name} = ".json_encode($var_value)." ;\n";
            }
        }
        ?>
        </script>

        <!-- Javascript common files -->
        <?php
        if(!empty($layout[MY_Controller::JS_FILES]))
        {
            foreach ($layout[MY_Controller::JS_FILES] as &$js_file)
            {
                echo "<script src='".site_url()."js/{$js_file}.js?r={$version}' type='text/javascript'></script>\n";    
            }
        }
        ?>
    </head>
    <body>
        <div id="wrapper">
            <!--Page Header-->
            <div id="header">
            <?=$this->load->view("element/header")?>
            </div>

            <!--Page Content-->
            <div id="container">
                <div id="sidebar">
                <?=$this->load->view("element/sidebar")?>
                </div>
                <div id="main-column">
                <?=$this->load->view($layout[MY_Controller::VIEW_FILE])?>
                </div>
            </div>

            <!--Page Footer-->
            <div id="footer">
            <?=$this->load->view("element/footer")?>
            </div>
        </div>
    </body>
</html>